/*
 * Copyright (c) 2006-2018, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2018-11-5      SummerGift   first version
 */

#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>

/* defined the LED0 pin: PF7 */
#define LED0_PIN    GET_PIN(F, 7)
void cpu_usage_show_init();
#define POWER  GET_PIN(A, 2)
int main(void)
{
    rt_pin_mode(POWER, PIN_MODE_OUTPUT);
    rt_pin_write(POWER, PIN_LOW);
    cpu_usage_show_init();
    ioco_menu();
    wire_power_driver();
    return RT_EOK;
}
void cpu_usage_show()
{
    cpu_usage_init();
    while (1)
    {
        rt_uint8_t cpu_major, cpu_minor = 0;
        cpu_usage_get(&cpu_major, &cpu_minor);
        rt_kprintf("cpu major %d, cpu min %d \n", cpu_major, cpu_minor);
        rt_thread_delay(2000);

    }
}
static rt_thread_t tid1 = RT_NULL;
#define THREAD_PRIORITY         25
#define THREAD_STACK_SIZE       512
#define THREAD_TIMESLICE        5
void cpu_usage_show_init()
{
    tid1 = rt_thread_create("cpuusage",
                            cpu_usage_show, RT_NULL,
                            512,
                            THREAD_PRIORITY, THREAD_TIMESLICE);

    if (tid1 != RT_NULL)
        rt_thread_startup(tid1);
}